package javase_class_250913;

import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.Collection;

/**
 * ClassName: TestForeach
 * Package: javase_class_250913
 * Description:
 *
 * @Author harkjeans
 * @Create 2025/9/13 14:03
 * @Version 1.0
 */
public class TestForeach {
    @Test
    public void test01(){
        Collection coll = new ArrayList();
        coll.add("小李广");
        coll.add("扫地僧");
        coll.add("石破天");
        //foreach循环其实就是使用Iterator迭代器来完成元素的遍历的。
        for (Object o : coll) {
            System.out.println(o);
        }
    }
    @Test
    public void test02(){
        int[] nums = {1,2,3,4,5};
        for (int num : nums) {
            System.out.println(num);
        }
        System.out.println("-----------------");
        String[] names = {"张三","李四","王五"};
        for (String name : names) {
            System.out.println(name);
        }
    }
}
